package com.paziy.notes.core.notations;

import com.paziy.notes.core.notes.NoteValue;
import com.paziy.notes.core.sounds.Sound;

import java.util.Collection;
import java.util.LinkedList;

/**
 * Represents pitch. It is few sound which start at same point of time
 * and have same note value.
 * The empty pitch means pause!!!
 * @param <S> type of sound kept in pitch
 *
 * @author thecederick@gmail.com (Paziy Evgeniy)
 * @version 0.3
 * @since 0.1 (03.12.13 9:54)
 */
public class Pitch<S extends Sound> extends LinkedList<S> {

    /**
     * The note vale of pitch
     */
    private NoteValue noteValue;


    public Pitch(NoteValue noteValue) {
        super();
        this.noteValue = noteValue;
    }

    public Pitch(S sound, NoteValue noteValue) {
        this(noteValue);
        add(sound);
    }

    public Pitch(Collection<S> sounds, NoteValue noteValue) {
        this(noteValue);
        addAll(sounds);
    }

    /**
     * The note value of pitch
     * @return the note value of pitch
     */
    public NoteValue getNoteValue() {
        return noteValue;
    }

    /**
     * Returns true if the pitch is empty it meats the pause.
     * Returns false if the pitch holds at last one sound.
     *
     * @return true if pitch is pause
     */
    public boolean isPause() {
        return isEmpty();
    }

    @Override
    public String toString() {
        return noteValue.name() + "#" + super.toString();
    }
}
